import {ElMessage} from 'element-plus'
import {ElMessageBox} from 'element-plus'
import type {MorghulisMessageInterface, MorghulisMessageBoxInterface} from "../types/feedback.types";

export const $message: MorghulisMessageInterface = {
    info: (message: string) => ElMessage({message, type: 'info', grouping: true}),
    success: (message: string) => ElMessage({message, type: 'success', grouping: true}),
    warning: (message: string) => ElMessage({message, type: 'warning', grouping: true}),
    error: (message: string) => ElMessage({message, type: 'error', grouping: true}),
}

export const $alert: MorghulisMessageBoxInterface = {
    info: (message: string, title?: string) => ElMessageBox.alert(message, title, {type: 'info'}),
    success: (message: string, title?: string) => ElMessageBox.alert(message, title, {type: 'success'}),
    warning: (message: string, title?: string) => ElMessageBox.alert(message, title, {type: 'warning'}),
    error: (message: string, title?: string) => ElMessageBox.alert(message, title, {type: 'error'}),
}

export const $confirm: MorghulisMessageBoxInterface = {
    info: (message: string, title?: string) => ElMessageBox.confirm(message, title, {type: 'info'}),
    success: (message: string, title?: string) => ElMessageBox.confirm(message, title, {type: 'success'}),
    warning: (message: string, title?: string) => ElMessageBox.confirm(message, title, {type: 'warning'}),
    error: (message: string, title?: string) => ElMessageBox.confirm(message, title, {type: 'error'}),
}